package com.zyz.demo.model;

import com.zyz.demo.enums.ResultStatusEnums;
import lombok.Data;

@Data
public class Result<T> {
    private ResultStatusEnums code;
    private String errMsg;
    private T data;


    public static <T> Result success(T data) {
        Result result = new Result();
        result.setCode(ResultStatusEnums.SUCCESS);
        result.setData(data);
        return result;
    }

    public static Result noLogin() {
        Result result = new Result();
        result.setCode(ResultStatusEnums.NO_LOGIN);
        result.setErrMsg("用户未登录");
        return result;
    }

    public static Result fail(String errMsg) {
        Result result = new Result();
        result.setErrMsg(errMsg);
        result.setCode(ResultStatusEnums.FAIL);
        return result;
    }
}
